/**
 * 
 */
package controllers.wechatlab;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.textplantform.common.core.ClassificationPair;
import org.textplantform.common.provider.ClassificationService;

import controllers.BaseController;
import pojo.dto.services.TCClassifyResult;

/**
 * 调用deep4jworkbenc的CONTROLLER接口
 * @author alex
 *
 */
@Controller
@RequestMapping(value="admin/doc")
public class CNNNetworkController extends BaseController{
	@Autowired
	ClassificationService cs;
	@RequestMapping(value="predict.do")
	@ResponseBody  public String cnnPredict(HttpServletRequest req,HttpServletResponse res){
		String doc = req.getParameter("doc");
		TCClassifyResult x = new TCClassifyResult(); 
		ClassificationPair[] data = null;
		try{
		 data= cs.classifyDocument(doc);
		}catch(Exception e){
			data = new ClassificationPair[1];
			data[0] = new ClassificationPair("error", 0);
		}
		x.setData(data);
		return jsonDump(x);
	}
	@RequestMapping(value="update.do")
	@ResponseBody  public String cnnUpdate(HttpServletRequest req,HttpServletResponse res){
		return jsonDump(SUCCESS);
//		return jsonDump(new TCAddDocumentAPI(req).convenienceFire().javaClassResult());
	}

}
